<?php
/* admenu4.php 2006-07-02 12:48:44
   Conference Registration - Registration for conferences - A XOOPS CMS Module
   Copyright (c) 2006 Kevin van Haaren, US
   URL:     http://www.superfantasmoworld.com/
   Contact: kevin@vanhaaren.net
 	
   XOOPS
   Copyright (c) 2000 XOOPS.org
   URL:     http://www.xoops.org/
    
   This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    
 */
 
//The next comment block is for PHPDocumentor
/**
 * Conference Registration - Registration for conferences
 * 
 * Admin menu option:
 * Edit a group or registrant
 * 
 * @author Kevin van Haaren (kevin@vanhaaren.net)
 * @copyright 2006 Kevin van Haaren, US
 * @package CONFREG
 * @subpackage Admin_Function
 * 
 */

/**
* Do all the declarations etc needed by an admin page
*/
include_once "adminheader.inc";

//Display the admin menu
xoops_module_admin_menu(5,_AM_CONFREG_ADMENU4);

// clean data passed to the form
$cleanPost = cleanInput($_POST);
$submit = $cleanPost['submit'];

// no options selected yet
if (!isset($cleanPost['confid'])) {
	// show the conferences in the database
	$conferences = get_list_confs();

	echo "<table width=90%>";
	echo '<tr><th style="text-align:center;">Conf<br />ID</th><th width=33% style="text-align:center;">Title</th><th style="text-align:center;">Start Date</th><th style="text-align:center;">End Date</th><th style="text-align:center;">Reg Open</th><th style="text-align:center;">Reg Close</th><th>&nbsp;</th></tr>';
	if (count($conferences) > 0) {
		foreach ($conferences as $confData) {
			echo "<tr>";
			echo '<td style="text-align:center;">' . $confData['confid'] . "</td>";
			echo "<td>" . $confData['title'] . "</td>";
			echo '<td style="text-align:right;">' . substr($confData['start_date'],0,10) . "</td>";
			echo '<td style="text-align:right;">' . substr($confData['end_date'],0,10) . "</td>";
			echo '<td style="text-align:right;">' . substr($confData['reg_start'],0,10) . "</td>";
			echo '<td style="text-align:right;">' . substr($confData['reg_end'],0,10) . "</td>";
			echo '<td style="text-align:center;"><form action="admenu4.php" method=post><input type=hidden name=confid value=' . $confData['confid'] . '><input type=submit value="Show Groups"></form></td>';
			echo "</tr>";
		}
	} else {
		echo "<tr><td colspan=6>No conferences defined yet.</td></tr>";
	}
	echo "</table></div><br /><br />";
} elseif ((isset($cleanPost['confid'])) and (!isset($cleanPost['groupid']))) {
	$groups = get_list_groups(intval($cleanPost['confid']));
	echo "<table width=90%>";
	echo '<tr><th style="text-align:center;">Group<br />ID</th><th width=35% style="text-align:center;">Company</th><th style="text-align:center;">Billing<br>First Name</th><th style="text-align:center;">Billing<br>Last Name</th><th width=20% style="text-align:center;">Confirmation<br>E-mail</th><th>&nbsp;</th></tr>';
	if (count($groups) > 0) {
		foreach ($groups as $groupData) {
			echo "<tr>";
			echo '<td style="text-align:center;">' . $groupData['groupid'] . "</td>";
			echo "<td>" . $groupData['company'] . "</td>";
			echo '<td style="text-align:left;">' . $groupData['bill_fname'] . "</td>";
			echo '<td style="text-align:left;">' . $groupData['bill_lname'] . "</td>";
			echo '<td style="text-align:left;">' . $groupData['confirm_email'] . "</td>";
			echo '<td style="text-align:center;"><form action="admenu4.php" method=post><input type=hidden name=confid value=' . intval($confid) . '><input type=hidden name=groupid value=' . $groupData['groupid'] . '><input type=submit value="Create Receipt"></form></td>';
			echo "</tr>";
		}
	} else {
		echo "<tr><td colspan=5>No groups defined yet.</td></tr>";
	}
} elseif ((isset($cleanPost['confid'])) and (isset($cleanPost['groupid']))) {

	$confid = intval($cleanPost['confid']);
	$groupid = intval($cleanPost['groupid']);

	$gData = get_group_data($groupid);

	echo '<form action="sendreceipt.php" method="post">';
	echo '<input type="hidden" name="confid" value="' . $confid . '">';
	echo '<input type="hidden" name="groupid" value="' . $groupid . '">';
	if (isset($gData['confirm_email'])) {
		echo '<input id="email" name="email" type="text" value="' . $gData['confirm_email'] . '"/>&nbsp;&nbsp;';
	} else {
		echo '<input id="email" name="email" type="text" />&nbsp;&nbsp;';
	}
	echo '<input type="submit" name="submit" value="' . _AM_CONFREG_EMAIL_RECEIPT . '" /><br />';
	echo '</form>';

	echo '<br /><br /><table border="1">';
	echo '<tr><th colspan="2">Company Information</th></tr>';
	echo '<tr><td style="text-align:right">Company:</td>';
	echo '<td>' . $gData['company'] . '</td></tr>';

	echo '<tr><td style="vertical-align:top; text-align:right">Mailing Address:</td>';
	echo '<td>';
	echo (empty($gData['mailaddress1'])) ? '&nbsp;' : $gData['mailaddress1'];
	echo (empty($gData['mailaddress2'])) ? '&nbsp;' : ('<br />' . $gData['mailaddress2']);
	echo ($gData['mailcity'] . $gData['mailstate'] . $gData['mailzip'] === '') ? '&nbsp;' : ('<br />' . $gData['mailcity'] . ', ' . $gData['mailstate'] . ' ' . $gData['mailzip']);
	echo '</td></tr>';

	echo '<tr><td style="vertical-align:top; text-align:right">Billing Name:</td>';
	echo '<td>';
	echo ($gData['bill_fname'] . $gData['bill_lname'] === '') ? '&nbsp;' : ($gData['bill_fname'] . ' ' . $gData['bill_lname']);
	echo '</td></tr>';
 		
	echo '<tr><td style="vertical-align:top; text-align:right">Billing Address:</td>';
	echo '<td>';
	echo (empty($gData['billaddress1'])) ? '&nbsp;' : $gData['billaddress1'];
	echo ($gData['billcity'] . $gData['billstate'] . $gData['billzip'] === '') ? '&nbsp;' : ('<br />' . $gData['billcity'] . ', ' . $gData['billstate'] . ' ' . $gData['billzip']);
	echo '</td></tr>';

	echo '<tr><td style="text-align:right">Confirmation E-mail:</td>';
	echo '<td>';
	echo (empty($gData['confirm_email'])) ? '&nbsp;' : $gData['confirm_email'];
	echo '</td></tr>';

	echo '<tr><td style="text-align:right">Pay By:</td>';
	echo '<td>' . ((empty($gData['paytype'])) ? '&nbsp;' : $gData['paytype']) . '</td></tr>';
	echo '<tr><td style="text-align:right">Total Cost:</td>';
	echo '<td>' . ((empty($gData['total_cost'])) ? '$0.00' : dollarfy($gData['total_cost'],2)) . '</td></tr>';
	echo '<tr><td style="text-align:right">Amount Paid:</td>';
	echo '<td>' . ((empty($gData['AmountPaid'])) ? '$0.00' : dollarfy($gData['AmountPaid'],2)) . '</td></tr>';

	echo '<tr><th colspan="2">Attendee Information</th></tr>';
	$users = get_group_users($groupid);

	$i = 1;
	$total_cost = 0;

	foreach ($users as $peopleData) {
		$workshops = get_user_workshops($peopleData['userid']);
		
		echo '<tr><th colspan="2">Attendee:' . $i . '</th></tr>';
		echo '<tr><td style="text-align:right">Name:</td>';
		echo '<td>';
		echo ($peopleData['first_name'] . $peopleData['last_name'] === '') ? '&nbsp;' : ($peopleData['first_name'] . ' ' . $peopleData['last_name']);
		echo '</td>';

		echo '<tr><td style="text-align:right">TMC Number:</td>';
		echo '<td>' . ((empty($peopleData['tmc_num'])) ? '&nbsp;' : $peopleData['tmc_num']) . '</td></tr>';

		echo '<tr><td style="text-align:right">E-mail:</td>';
		echo '<td>' . ((empty($peopleData['email'])) ? '&nbsp;' : $peopleData['email']) . '</td></tr>';

		echo '<tr><td style="text-align:right">Days Attending:</td>';
		echo '<td>' . ((empty($peopleData['days_attending'])) ? '&nbsp;' : $peopleData['days_attending']) . '</td></tr>';

		$wCount = 1;
		foreach ($workshops as $wshop) {
			echo '<tr><td style="text-align:right">Workshop ' . $wCount . ':</td>';
			echo '<td>' . ((empty($wshop['title'])) ? '&nbsp;' : $wshop['title']) . '</td></tr>';
			$wCount++;
		}

		echo '<tr><td style="text-align:right">Cost This Person:</td>';
		echo '<td>' . ((empty($peopleData['cost'])) ? '&nbsp;' : dollarfy($peopleData['cost'],2)) . '</td></tr>';

		$i++;
	}
	echo "</table></div><br /><br />";

}

echo '<p><p>';
//put footer in
xoops_cp_footer();

/*
 * This file was generated by XBS ModGen, (c) 2006 A Kitson, UK. See http://xoobs.net
 * ModGen is a Module Code Generator for the Xoops CMS.  See http://xoops.org
 */
?>